<!-- 横向选项卡（水平滚动导航栏） -->
<template>
	<view class="tab-Navbox">
		<!-- 顶部导航栏 -->
		<view class="horizonal-tab">
			<scroll-view scroll-x="true" scroll-with-animation class="scroll-tab">
				<block v-for="(item,index) in tabBars" :key="index">
					<view class="scroll-tab-item" :class="{'active': tabIndex==index}" @tap="toggleTab(index)">
						{{item.name}}
						<view class="scroll-tab-line"></view>
					</view>
				</block>
			</scroll-view>
				<view class="iconfont icon-fenleiorguangchangorqita  nav-fenle"></view>
		</view>

		<!-- 内容区 -->
		<view class="content content-bigbox">
			
			<!-- 滑块视图 -->
			<swiper :current="tabIndex" @change="tabChange" class="swiper_car">
				<!-- current:当前所在滑块的index -->
				<swiper-item v-for="(content,index) in contentList" :key="index" >
					<view class="content">
					<text class="messageTitle">{{content}}</text>
					</view>
					<carDeck class="box-imgas"></carDeck>
				</swiper-item>
			</swiper>
			
		</view>


	</view>
</template>

<script>
// import '@/static/font_4005658_ghrolpqeg6q/iconfont.css';
    import carDeck from '../../pages/carDeck/carDeck.vue'
	
	export default {
		name:'NarBar',
	  components:{
		carDeck,
	    },
		data() {
			return {
				tabIndex: 0,
				/* 选中标签栏的序列,默认显示第一个 */
				contentList: [
					"更新",
					"推荐",
					"人气",
					"审美",
					'更新',
					'男生',
					'女生',
					'新人',
					'玄幻',
					'奇幻',
				],
				tabBars: [{
						name: '更新',
						id: '1'
					},
					{
						name: '推荐',
						id: '2'
					},
					{
						name: '人气',
						id: '3'
					},
					{
						name: '审美',
						id: '4'
					},
					{
						name: '推理',
						id: '5'
					},
					{
						name: '男生',
						id: '6'
					},
					{
						name: '女生',
						id: '7'
					},
					{
						name: '奇幻',
						id: '8'
					},
					{
						name: '玄幻',
						id: '9'
					},
					{
						name: '新人',
						id: '10'
					}
				]
			}
		},
	
		methods: {
			//切换选项卡
			toggleTab(index) {
				this.tabIndex = index;
			},
			//滑动切换swiper
			tabChange(e) {
				console.log(e);
				this.tabIndex = e.detail.current;
			}
		}
	}
</script>

<style>
	.box-imgas{
		display: flex;
		flex-wrap: wrap;
		
	}
	.swiper_car{
		max-height: 1600px;
		height: 800px;

	}
	.horizonal-tab {}

	.horizonal-tab .active {
		color: red;
	}
	.tab-Navbox{
		width: 100%;
		 
	}
	/* 大标题 */
	.content{
     width: 100%;
	 position: relative;
	}
	.messageTitle{
		width: 100%;
		padding: 10px;
		 position: absolute;
		
	}
	/* 内容盒子 */
	.content-bigbox{
		width: 100%;
		height: 500px;
        max-height: 800px;
		margin-top: 238px;
		background-color: white;
		border-radius: 12px 12px 0px 0px;
	   box-shadow: -5px -5px 30px rgba(226, 226, 226, 0.9) /*blur值为5px*/ 
	
	}

	.scroll-tab {
		white-space: nowrap;
		/* 必要，导航栏才能横向*/
		border-bottom: 1rpx solid #eee;
		text-align: center;
		width: 90%;
		
	}

	.scroll-tab-item {
		display: inline-block;
		/* 必要，导航栏才能横向*/
		margin: 20rpx 30rpx 0 30rpx;
	}

	.active .scroll-tab-line {
		border-bottom: 5rpx solid red;
		border-top: 5rpx solid red;
		border-radius: 20rpx;
		width: 70rpx;
	}
	
	
	.nav-fenle{
		float: right;
		position: absolute;
		right: 8px;
		top:12px;
	
	}

	
</style>

